<?php

namespace Core;

class Paths {

    private static $objInstance;

    private $arrMembers;
    private $boolAccessed = false;

    function __construct () {
        $this->arrMembers['Application'] = "../app/";
        $this->arrMembers['Controllers'] = "../app/Controllers/";
        $this->arrMembers['Definitions'] = "../app/Data/Definitions/";
        $this->arrMembers['Library'] = "../app/Library/";
        $this->arrMembers['Models'] = "../app/Data/Models/";
        $this->arrMembers['Views'] = "../app/Views/";
    }

    function __get ( $strName ) {

        if ( array_key_exists( $strName, $this->arrMembers ) ) {

            if ( $this->boolAccessed == false ) {
                // This is the first time a path is accessed, so now we lock the paths.
                
                $this->boolAccessed = true;

                // Modify include path to include path to library.
                ini_set( 'include_path', ini_get( 'include_path' ) . PATH_SEPARATOR . $this->arrMembers['Library'] );


            }
            
            return $this->arrMembers[$strName];

        } else {

            // TODO: Throw an exception.

        }

    }

    function __set ( $strName, $strValue ) {
        if ( $this->boolAccessed ) {
            throw new \RuntimeException( "Core\Directories has already been accessed and cannot be changed." );
        }
    }

    /**
     * Gets an instance of itself.
     *
     * @return Core\Directories
     */
    public static function getInstance () {

        if ( !self::$objInstance instanceof self )
            self::$objInstance = new self;

        return self::$objInstance;

    }

}

?>
